package org.melanesia.beans;

import java.util.Map;

/**
 * Setter implementation for {@link java.util.Map} collections.
 * 
 * @author marcin.kielar
 * 
 */
class MapSetter implements Setter {

    /** Property name. */
    private final String property;

    /**
     * Constructs new <code>MapSetter</code> with giver property name.
     * 
     * @param property
     *            property name
     */
    MapSetter(final String property) {
        this.property = property;
    }

    @Override
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public void set(final Object bean, final Object value, final Map<String, Class<?>> intermediateBeanClasses) {
        ((Map) bean).put(property, value);
    }

    @Override
    public Class<?> getAcceptedType() {
        return Object.class;
    }

}
